﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="LightWeb.DomainModel" namespace="LightWeb.DomainModel" default-lazy="false">
  <class name="User">
    <id name="PrimaryKey">
      <generator class="native">
      </generator>
    </id>
    <property name="FirstName" type="String" length="50"></property>
    <property name="LastName" type="String" length="50"></property>
    <property name="LoginName" type="String" length="50"></property>
    <property name="Password" type="String"></property>
    <property name="DisplayName" type="String"></property>
    <property name="Email" type="String" length="50"></property>

    <bag name="Roles" table="UserRole" inverse="false" lazy="false" cascade="all">
      <key column="UserID"/>
      <one-to-many class="UserRole"/>
    </bag>
  </class>
  <class name="Role">
    <id name="PrimaryKey">
      <generator class="native">
      </generator>
    </id>
    <property name="Name" type="String" length="50"></property>
    <!--<set name="Users" table="UserRole" inverse="false" lazy="false">
      <key column="RoleID"/>
      <one-to-many class="UserRole"/>
    </set>-->
  </class>
  <class name="UserRole">
    <!--<id name="PrimaryKey">
      <generator class="native">
      </generator>
    </id>-->
    <composite-id>
      <key-many-to-one name="UserID" class="User" column="UserID" ></key-many-to-one>
      <key-many-to-one name="RoleID" class="Role" column="RoleID" ></key-many-to-one>
    </composite-id>
  </class>

</hibernate-mapping>